﻿using System;

namespace SharpTrainer.Event
{
    public class Stock
    {
        private string symbol;
        private decimal price;

        public Stock(string symbol) 
        { 
            this.symbol = symbol; 
        }

        public event EventHandler<PriceChangedEventArgs> PriceChanged;
        
        protected virtual void OnPriceChanged(PriceChangedEventArgs e)
        {
            if (PriceChanged != null) PriceChanged(this, e);
        }

        public decimal Price
        {
            get { return price; }

            set
            {
                decimal oldPrice = price;
                price = value;
                OnPriceChanged(new PriceChangedEventArgs(oldPrice, price));
            }
        }
    }
}
